package com.happyrecyclingstation.controller;

import com.happyrecyclingstation.dto.LoginDto;
import com.happyrecyclingstation.service.LoginService;
import com.happyrecyclingstation.utils.Result;
import com.happyrecyclingstation.vo.LoginVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录和注册
 */
@Slf4j
@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 登录
     * @param loginDto
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody LoginDto loginDto) {
        log.info("登录请求：{}", loginDto);
        LoginVO loginVo = loginService.login(loginDto);
        return Result.success(loginVo);
    }
}
